package de.hsfulda.et.problemloesen.ws1112.grp2.knapsack;

import java.util.Iterator;
import java.util.ArrayList;

public class KnapsackItem {
	
	public static int totalnumberitems;

	/* 0 is weigth
	 * 1 is value
	 * 2 is volume
	 * for more use 'setData'
	 */
	private ArrayList<Long> data = 
			new ArrayList<Long>(3); 				
	
	public KnapsackItem(ArrayList<Long> data) {
		this.data = data;
	}

	public KnapsackItem(Long weight, Long value) {
		this.data.add(0, new Long (weight));
		this.data.add(1, new Long (value));
		this.data.add(2, new Long(1L));
	}

	public KnapsackItem(Long weight) {
		this.data.add(0, weight);
		this.data.add(1, new Long(1L));
		this.data.add(2, new Long(1L));
	}

	public KnapsackItem(Long weight, Long value, Long volume) {
		this.data.add(0, weight);
		this.data.add(1, value);
		this.data.add(2, volume);
	}

	public Long getVolume() {
		return data.get(2);
	}

	public void setVolume(Long volume) {
		this.data.add(2, volume);
	}

	public Long getValue() {
		return data.get(1);
	}

	public void setValue(Long value) {
		this.data.add(1, value);
	}

	public Long getWeight() {
		return data.get(0);
	}

	public void setWeight(Long weight) {
		this.data.add(0, weight);
	}

	public ArrayList<Long> getData() {
		return data;
	}

	public void setData(ArrayList<Long> data) {
		this.data = data;
	}
	
	public String toString()
	{
	    String toReturn = "";
	    for (Iterator iterator = data.iterator(); iterator.hasNext();) {
		Long entry = (Long) iterator.next();
		//toReturn.concat(entry.toString() + " ");	
		toReturn += (entry.toString() + " ");
	    }
	    return toReturn;
	}

}
